<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TabbedWPFSample"
    xmlns:awe="http://schemas.awesomium.com/winfx"
    xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/TabbedWPFSample;component/Themes/WebTabControl.xaml"/>
        <ResourceDictionary Source="/TabbedWPFSample;component/Themes/ContentSpinner.xaml"/>
        <ResourceDictionary Source="/TabbedWPFSample;component/Themes/CircularProgressBar.xaml"/>
        <ResourceDictionary Source="/TabbedWPFSample;component/Themes/DownloadsControl.xaml"/>
        <ResourceDictionary Source="/TabbedWPFSample;component/Themes/TabView.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

    <Style TargetType="{x:Type local:MainWindow}" BasedOn="{StaticResource {x:Type Window}}">
        <Setter Property="Icon" Value="/TabbedWPFSample;component/Images/Awesomium.ico" />
        <Setter Property="MinWidth" Value="400" />
        <Setter Property="MinHeight" Value="300" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="Title">
            <Setter.Value>
                <Binding 
                    Path="SelectedView.Browser.Title" 
                    RelativeSource="{RelativeSource Self}" 
                    StringFormat="Awesomium Tabbed WPF Sample - {0}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MainWindow}">
                    <Border x:Name="ContentBorder" SnapsToDevicePixels="True">
                        <Grid x:Name="ContentGrid" Background="#FFD2E6FA">
                            <!-- Wrap within an AdornerDecorator or else there will be no
                                 adorner layer for the window. This means that ErrorTemplates
                                 will also not be visible. -->
                            <AdornerDecorator>
                                <Grid Margin="0,1,0,0">
                                    <Grid.RowDefinitions>
                                        <RowDefinition />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <local:WebTabControl 
                                        DataContext="{TemplateBinding Views}" 
                                        ItemsSource="{Binding}"/>
                                    <local:DownloadsControl 
                                        Grid.Row="1" 
                                        Background="#FFD2E6FA"
                                        BorderThickness="1" 
                                        BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" 
                                        Height="50"
                                        Source="{TemplateBinding Downloads}"
                                        Visibility="{Binding DownloadsVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                </Grid>
                            </AdornerDecorator>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsGlassEnabled, Source={x:Static shell:SystemParameters2.Current}}" Value="True">
                            <Setter Property="shell:WindowChrome.WindowChrome">
                                <Setter.Value>
                                    <shell:WindowChrome GlassFrameThickness="8,30,8,8" ResizeBorderThickness="8"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="ContentBorder" Property="CornerRadius" Value="6" />
                            <Setter TargetName="ContentBorder" Property="Padding" Value="7,8,7,7" />
                            <Setter TargetName="ContentGrid" Property="Background" Value="{x:Null}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>
